package com.zslc.securitymonitoring.controller;

import com.zslc.securitymonitoring.service.RealTimeService;
import com.zslc.securitymonitoring.util.ResultCMS;
import com.zslc.securitymonitoring.vo.GlobalSeverityVO;
import com.zslc.securitymonitoring.vo.StatusStatistic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 今日事件
 *
 * @author Gyc
 */
@Slf4j
@RestController
@RequestMapping("/realtime")
public class RealTimeController {
    @Autowired
    private RealTimeService realtimeService;

    @GetMapping("/event/list")
    public ResultCMS listBy1Day() {
        try {
            List<GlobalSeverityVO> list = realtimeService.listBy1Day();
            return ResultCMS.success(list);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultCMS.fail_5000();
        }
    }

    @GetMapping("/status/statistic")
    public ResultCMS statusStatistic() {
        try {
            List<StatusStatistic> list = realtimeService.statusStatistic();
            return ResultCMS.success(list);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return ResultCMS.fail_5000();
        }
    }
}
